package com.idanchuang.support.etcache.annotation;

import com.idanchuang.support.etcache.local.LocalCacheConfig;
import com.idanchuang.support.etcache.remote.codec.JavaValueCodec;
import com.idanchuang.support.etcache.remote.codec.ValueCodec;

import java.lang.annotation.*;
import java.util.concurrent.TimeUnit;

/**
 *
 * 使用方式:
 *
 *     @CreateEtCache(name = "mycache")
 *     private EtCache<String, String> cache;
 *
 *     @GetMapping("get")
 *     public String get(String key) {
 *         return cache.get(key);
 *     }
 *
 *     @PostMapping("set")
 *     public String set(String key, String value) {
 *         cache.set(key, value);
 *         return "OK";
 *     }
 *
 * @author yjy
 * Created at 2021/12/30 1:33 下午
 */
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface CreateEtCache {

    String name() default "";

    long localExpire() default LocalCacheConfig.DEFAULT_EXPIRE;

    TimeUnit localTimeUnit() default TimeUnit.MILLISECONDS;

    long localLimit() default LocalCacheConfig.DEFAULT_MAXIMUM_SIZE;

    Class<? extends ValueCodec> keyCodec() default JavaValueCodec.class;

    Class<? extends ValueCodec> valueCodec() default JavaValueCodec.class;


}
